<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>

</head>
<body>
    <div id="app">
        {{firstName+' '+lastName}}
        {{fullName}}
    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                firstName:'Dell',
                lastName:'Lee',
                age:23
                
                
            },
            // 计算属性,内置缓存的(就是只要变量不改变,就不会重新调用)
            computed:{
                // fullName(){
                //     return this.firstName+this.lastName
                // }
                // 计算属性是有getset 方法
                fullName:{
                    get(){
                        return this.firstName+this.lastName
                    },
                    set(value){
                        var arr = value.split(' ')
                        this.firstName = arr[0]
                        this.lastName = arr[1]
                    }
                }
            },
            // 侦听器,强行监听每一个变量(按照变量名称来监听)
            // watch:{
            //     firstName(){
            //         this.fullName=this.firstName+this.lastName
            //     },
            //     lastName(){
            //         this.fullName=this.firstName+this.lastName
            //     }
            // }

        })
    </script>
</body>
</html>